import request from '@/utils/http'

const apiList = {
    allRole: 'role/findAll',
    addRole: 'role/addBaseInfo',
    updateRole: 'role/update',
    deleteRole: 'role/delete',
    allMenu: 'menu/all',
    hasMenu: 'menu/getRoleHasMenu',
    setRoleMenu: 'role/updateRoleMenu',

    user: 'admin/list',
    deleteUser: 'admin/delete',
    updateUser: 'admin/update',
    addUser: 'admin/add',
    allotRole: 'admin/updateAdminRole',

    addMenu: 'menu/add',
    updateMenu: 'menu/update',
}

export default {
    deleteMenu: data => {
        return request.get(`menu/delete/${data.id}`)
    },
    updateMenu: data => {
        return request.post(apiList.updateMenu, data)
    },
    addMenu: data => {
        return request.post(apiList.addMenu, data)
    },

    allotRole: data => {
        return request.post(apiList.allotRole, data)
    },
    addUser: data => {
        return request.post(apiList.addUser, data)
    },
    updateUser: data => {
        return request.post(apiList.updateUser, data)
    },
    deleteUser: data => {
        return request.get(apiList.deleteUser, { params: data })
    },
    user: data => {
        return request.post(apiList.user, data)
    },

    allRole: data => {
        return request.get(apiList.allRole, { params: data })
    },
    addRole: data => {
        return request.post(apiList.addRole, data)
    },
    updateRole: data => {
        return request.post(apiList.updateRole, data)
    },
    deleteRole: data => {
        return request.delete(apiList.deleteRole, { params: data })
    },
    allMenu: data => {
        return request.get(apiList.allMenu, { params: data })
    },
    hasMenu: data => {
        return request.get(apiList.hasMenu, { params: data })
    },
    setRoleMenu: data => {
        return request.post(apiList.setRoleMenu, data)
    }
}